<?php
$rows = file($argv[1]);
$q = array();
foreach ($rows as $k => $row) {
	if (0 < $k) {
		//需要统计第2题-第34题
		$answers = explode(',', $row);
		for ($i = 2; $i <= 34; $i++) {
			$q[$i][trim($answers[$i])]++;
		}
	}
}
$qCount = array();
for ($i = 2; $i <= 34; $i++) {
	for ($j = 1; $j <= 5; $j++) {
		$qCount[$i][$j] += $q[$i][$j];
	}
}

echo 'if Q2=1,Q3=1;if Q2=2-5,Q3=2-5', "\n";
echo 'Q2 1/Q3 1:', 100*getSum($qCount,2,1,1)/getSum($qCount,3,1,1), "\n";
echo 'Q2 2-5/Q3 2-5:', 100*getSum($qCount,2,2,5)/getSum($qCount,3,2,5), "\n";
echo "\n";

echo 'Q2 1:',getSum($qCount,2,1,1)/getSum($qCount,2,1,5), "\n";
echo 'Q2 2:',getSum($qCount,2,2,2)/getSum($qCount,2,1,5), "\n";
echo 'Q2 3:',getSum($qCount,2,3,3)/getSum($qCount,2,1,5), "\n";
echo 'Q2 4:',getSum($qCount,2,4,4)/getSum($qCount,2,1,5), "\n";
echo 'Q2 5:',getSum($qCount,2,5,5)/getSum($qCount,2,1,5), "\n";
echo "\n";

echo 'Q3 1:',getSum($qCount,3,1,1)/getSum($qCount,3,1,5), "\n";
echo 'Q3 2:',getSum($qCount,3,2,2)/getSum($qCount,3,1,5), "\n";
echo 'Q3 3:',getSum($qCount,3,3,3)/getSum($qCount,3,1,5), "\n";
echo 'Q3 4:',getSum($qCount,3,4,4)/getSum($qCount,3,1,5), "\n";
echo 'Q3 5:',getSum($qCount,3,5,5)/getSum($qCount,3,1,5), "\n";
echo "\n";


echo 'if Q4=3-5, Q6 98% 3-5, Q5 100% 1-2, Q4 60% 3-5', "\n";
echo 'Q4 3-5:', 100*getSum($qCount,4,3,5)/getSum($qCount,4,1,5), "\n";
echo 'Q6 3-5/Q4 3-5:', 100*getSum($qCount,6,3,5)/getSum($qCount,4,3,5), "\n";
echo 'Q5 1-2/Q4 3-5:', 100*getSum($qCount,5,1,2)/getSum($qCount,4,3,5), "\n";
echo "\n";
echo 'if Q7 3-5,  Q8 95% 3-5,Q9 90% 3-5 ,Q7 75% 3-5', "\n";
echo 'Q7 3-5:', 100*getSum($qCount,7,3,5)/getSum($qCount,7,1,5), "\n";
echo 'Q8 3-5/Q7 3-5:', 100*getSum($qCount,8,3,5)/getSum($qCount,7,3,5), "\n";
echo 'Q9 3-5/Q7 3-5:', 100*getSum($qCount,9,3,5)/getSum($qCount,7,3,5), "\n";
echo "\n";
echo 'if Q10 3-5, 95% Q11 3-5, Q10 75% 3-5', "\n";
echo 'Q10 3-5:', 100*getSum($qCount,10,3,5)/getSum($qCount,10,1,5), "\n";
echo 'Q11 3-5/Q10 3-5:', 100*getSum($qCount,11,3,5)/getSum($qCount,10,3,5), "\n";
echo "\n";
echo 'IF Q12 3-5, Q13 95% 3-5, Q14 85% 3-5, Q15 85%3-5, Q12 80% 3-5', "\n";
echo 'Q12 3-5:', 100*getSum($qCount,12,3,5)/getSum($qCount,12,1,5), "\n";
echo 'Q13 3-5/Q12 3-5:', 100*getSum($qCount,13,3,5)/getSum($qCount,12,3,5), "\n";
echo 'Q14 3-5/Q12 3-5:', 100*getSum($qCount,14,3,5)/getSum($qCount,12,3,5), "\n";
////echo 'Q15 3-5/Q12 3-5:', 100*getSum($qCount,15,3,5)/getSum($qCount,12,3,5), "\n";
echo "\n";
echo 'IF Q16 2-5, 80% Q17 2-5, Q16 70% 2-5', "\n";
echo 'Q16 3-5:', 100*getSum($qCount,15,3,5)/getSum($qCount,15,1,5), "\n";
echo 'Q17 3-5/Q16 3-5:', 100*getSum($qCount,16,3,5)/getSum($qCount,15,3,5), "\n";
echo "\n";
echo 'IF Q17 3-5, 100% Q18 3-5', "\n";
echo 'Q18 3-5/Q17 3-5:', 100*getSum($qCount,17,3,5)/getSum($qCount,16,3,5), "\n";
echo "\n";
echo 'IF Q19 3-5,100% Q20 3-5, 98% q21 3-5, Q19 100% 3-5', "\n";
echo 'Q19 3-5:', 100*getSum($qCount,18,3,5)/getSum($qCount,18,1,5), "\n";
echo 'Q20 3-5/Q19 3-5:', 100*getSum($qCount,19,3,5)/getSum($qCount,18,3,5), "\n";
echo 'Q21 3-5/Q19 3-5:', 100*getSum($qCount,20,3,5)/getSum($qCount,18,3,5), "\n";
echo "\n";


echo 'if Q22 3-5, Q23 100% 3-5, Q24 98% 3-5, IF Q22=4-5, Q2 98% 3-5, Q22 3-5 85%', "\n";
echo 'Q22 3-5:', 100*getSum($qCount,21,3,5)/getSum($qCount,21,1,5), "\n";
echo 'Q23 3-5/Q22 3-5:', 100*getSum($qCount,22,3,5)/getSum($qCount,21,3,5), "\n";
echo 'Q24 3-5/Q22 3-5:', 100*getSum($qCount,23,3,5)/getSum($qCount,21,3,5), "\n";
echo 'Q2 3-5/Q22 3-5:', 100*getSum($qCount,2,3,5)/getSum($qCount,21,3,5), "\n";
echo 'Q2 3-5/Q23 3-5:', 100*getSum($qCount,2,3,5)/getSum($qCount,22,3,5), "\n";
echo "\n";

echo '80% 3-5分, if Q25 3-5, 100% Q26 3-5', "\n";
echo 'Q25 3-5:', 100*getSum($qCount,24,3,5)/getSum($qCount,24,1,5), "\n";
echo 'Q25 2:', 100*getSum($qCount,24,2,2)/getSum($qCount,24,1,5), "\n";
echo 'Q25 1:', 100*getSum($qCount,24,1,1)/getSum($qCount,24,1,5), "\n";
echo 'Q26 3-5/Q25 3-5:', 100*getSum($qCount,25,3,5)/getSum($qCount,24,3,5), "\n";
echo "\n";

echo 'if Q11 3-5，Q32 100% 3-5', "\n";
echo 'Q32 3-5:', 100*getSum($qCount,31,3,5)/getSum($qCount,31,1,5), "\n";
echo 'Q11 3-5/Q32 3-5:', 100*getSum($qCount,11,3,5)/getSum($qCount,31,3,5), "\n";
echo "\n";

echo 'if Q25 3-5, Q33 100% 3-5', "\n";
echo 'Q33 3-5:', 100*getSum($qCount,32,3,5)/getSum($qCount,32,1,5), "\n";
echo 'Q25 3-5/Q33 3-5:', 100*getSum($qCount,24,3,5)/getSum($qCount,32,3,5), "\n";
echo "\n";

echo 'Q34 85% 3-5, if Q3= 3-5, Q34 85% 3-5', "\n";

echo 'Q34 1:', 100*getSum($qCount,33,1,1)/getSum($qCount,33,1,5),'(', getSum($qCount,33,1,1), ')', "\n";
echo 'Q34 2:', 100*getSum($qCount,33,2,2)/getSum($qCount,33,1,5),'(', getSum($qCount,33,2,2), ')', "\n";
echo 'Q34 3:', 100*getSum($qCount,33,3,3)/getSum($qCount,33,1,5),'(', getSum($qCount,33,3,3), ')', "\n";
echo 'Q34 4:', 100*getSum($qCount,33,4,4)/getSum($qCount,33,1,5),'(', getSum($qCount,33,4,4), ')', "\n";
echo 'Q34 5:', 100*getSum($qCount,33,5,5)/getSum($qCount,33,1,5),'(', getSum($qCount,33,5,5), ')', "\n";
echo 'Q34 3-5:', 100*getSum($qCount,33,3,5)/getSum($qCount,33,1,5), "\n";
echo 'Q34 3-5/Q3 3-5:', 100*getSum($qCount,33,3,5)/getSum($qCount,3,3,5), "\n";

//echo 'Q23 50% 3-5', "\n";
//echo 'Q23 3-5:', 100*getSum($qCount,23,3,5)/getSum($qCount,23,1,5), "\n";
//echo "\n";
//echo 'Q24 30% 3-5', "\n";
//echo 'Q24 3-5:', 100*getSum($qCount,24,3,5)/getSum($qCount,24,1,5), "\n";





exit();

function getSum($qCount, $Q, $answerMin, $answerMax) {
	$rt = 0;
	for ($i = $answerMin; $i <= $answerMax; $i++) {
		$rt += $qCount[$Q][$i];
	}
	return $rt;
}